import type { Resource } from './model';

import { requestClient } from '#/api/request';

enum Api {
  resourceDelete = '/sysResource/v1/deleteResource',
  resourceInfo = '/sysResource/v1',
  resourceList = '/sysResource/v1/pageList',
  resourceSave = '/sysResource/v1/save',
  resourceUpdate = '/sysResource/v1/updateResource',
}

/**
 * 按钮资源分页
 * @param params 分页参数
 * @returns 分页结果
 */
export function resourceList(data?: any) {
  return requestClient.post<Resource[]>(Api.resourceList, data);
}

/**
 * 按钮资源详情
 * @param resourceId id
 * @returns 详情
 */
export function resourceInfo(data: any) {
  return requestClient.post<Resource>(`${Api.resourceInfo}`, data);
}

/**
 * 按钮资源新增
 * @param data 参数
 */
export function resourceAdd(data: Partial<Resource>) {
  return requestClient.post<void>(Api.resourceSave, data);
}

/**
 * 按钮资源更新
 * @param data 参数
 */
export function resourceUpdate(data: any) {
  return requestClient.postWithMsg<void>(Api.resourceUpdate, data);
}

/**
 * 按钮资源删除
 * @param resourceIds ids
 */
export function resourceRemove(params) {
  return requestClient.get<void>(`${Api.resourceDelete}`, {
    params,
  });
}
